package gui;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;

import javax.swing.JList;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class TabsPane extends JTabbedPane {

	private static final long serialVersionUID = -8789027985902159691L;

	private DeletionTab d;
	
	public TabsPane (JList j){
		super();		
		this.addTab("Add", new EditionTab(j));
		
		d = new DeletionTab(j);
		
		this.addTab("Remove",d);
		this.addTab("Shell",new MiniShellTab(j));
		
		ChangeListener changeListener = new ChangeListener() {
		      public void stateChanged(ChangeEvent changeEvent) {
		        JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.getSource();
		        int index = sourceTabbedPane.getSelectedIndex();
		        //System.out.println("Tab changed to: " + sourceTabbedPane.getTitleAt(index));
		        
		        if(sourceTabbedPane.getTitleAt(index).equalsIgnoreCase("Remove")) {
		        	d.updateList();	
		        }
		       
		      }
		    };
		this.addChangeListener(changeListener);
	}

	

}
